package LC;

/**
 * @Classname LC617
 * @Description // https://leetcode-cn.com/problems/merge-two-binary-trees/ 树  一次ac
 * @Date 2021/4/21 16:35
 * @Created by yin
 */
public class LC617 {


    public TreeNode mergeTrees(TreeNode a, TreeNode b) {
        if (a == null && b == null) return null;
        if (a != null && b == null) {
            return a;
        }
        if (a == null) {
            return b;
        }
        int val = a.val + b.val;
        TreeNode treeNode = new TreeNode(val);
        treeNode.left = mergeTrees(a.left, b.left);
        treeNode.right = mergeTrees(a.right, b.right);
        return treeNode;
    }

}
